package model.action;

import java.util.List;
import model.exception.ActionException;
import datacontainer.ImmuTable;


/**
 * This class will delete a column from the workspace.
 * The user just needs to specify which
 * column to delete, and the object will delete it.
 * 
 * @author Michael Deng
 * 
 */
public class DeleteColumn extends ColumnAction {

    @Override
    public void setInput (String column, List<String> conditions) {
        super.setInput(column, conditions);
    }

    @Override
    public void execute (ImmuTable workSpace, ImmuTable rawData) {
        String myColumnName = super.getColumnName();
        int index = getWorkSpaceColumnIndex(workSpace, myColumnName);
        if (index != -1) {
            removeColumn(workSpace, index);
        }
        else {
            throw new ActionException("Column not found in workspace!");
        }
    }
}
